package com.catchu.pattern.creational.迭代器模式.e随机翻页迭代器;

import com.catchu.pattern.creational.迭代器模式.e随机翻页迭代器.aggregate.ArrayPayAggregate;
import com.catchu.pattern.creational.迭代器模式.e随机翻页迭代器.iterator.ArrayIterator;
import com.catchu.pattern.creational.迭代器模式.e随机翻页迭代器.iterator.Iterator;

import java.util.Collection;

public class Client {

    public static void main(String[] args) {
        ArrayPayAggregate arrayPayAggregate = new ArrayPayAggregate();
        arrayPayAggregate.calcSalary();

        Iterator iterator = new ArrayIterator(arrayPayAggregate);
        Collection list = iterator.getPage(1,2);
        print(list);
        System.out.println("=============");
        Collection list2 = iterator.getPage(2,2);
        print(list2);

        System.out.println("=============");
        Collection list3 = iterator.getPage(3,2);
        print(list3);

        System.out.println("=============");
        Collection list4 = iterator.getPage(1,4);
        print(list4);
    }

    public static void print(Collection col){
        java.util.Iterator iterator = col.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
